/** 
 * UIMA Annotation Mapper
 * Copyright (C) 2010  Nicolas Hernandez
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.univnantes.lina.uima.mapper.annotation.located;

import org.apache.uima.jcas.tcas.Annotation;

/**
 * 
 * Que manipule t'on ? si l'on utilise cette méthode ( Offset getAnnotationOffset (Annotation anAnnotation)) cela signifie que 
 * l'on manipule à la fois des Offset et des annotations ; 
 * il faudrait soit que des annotations soit que des AnnotationOffset
 * On a besoin d'accéder à un offset comme clé dans une hash Static String getTheAnnotationOffset(Annotation a)
 * et on a besoin de comparer deux offsets Static boolean haveTheSameOffset(Annotation a, Annotation b)
 * cela peut être que du static et des String ou bien un objet Offset
 * on opte pour du static string et l'on voit ensuite
 * @author hernandez
 *
 */
public class Offset {
	static final String SEPARATOR = " ";
	
	/**
	 * the offset
	 * /
	private String offset;
	
	/**
	 * 
	 * @param a
	 * /
	public Offset(Annotation a) {
		this.setOffset(buildOffset (a));
	}
	
	/**
	 * @return the offset
	 * /
	public String getOffset() {
		return offset;
	}

	/**
	 * @param offset the offset to set
	 * /
	public void setOffset(String offset) {
		this.offset = offset;
	}
	*/


	private final static String buildOffset (int begin, int end) {
		return begin + SEPARATOR + end;
	}

	public static String getOffset (Annotation a) {
		return buildOffset (a.getBegin(),a.getEnd());
	}
	
	public static String getOffset (LocatedAnnotation a) {
		return buildOffset (a.getBegin(),a.getEnd());
	}

	public static boolean haveSameOffset(Annotation a, Annotation b) {
		return ((a.getBegin() == b.getBegin()) && (a.getEnd() == b.getEnd()));
	}
}

